#!/usr/bin/env bash

db_name=trending_topic
#db_name='test'
topics_schema=(\
    "id         varchar(50)," \
    "topic      varchar(100),"\
    "description    varchar(500),"\
    "tags       varchar(100),"\
    "presenter  varchar(50),"\
    "presenter_link   varchar(500),"\
    "categories       varchar(100),"\
    "district       varchar(50)"\
)
topic_statis_schema=(\
    "id         varchar(50),"\
    "rank       integer,"\
    "num_readings   bigint,"\
    "num_discussion bigint,"\
    "num_fans       bigint,"\
    "timestamp  varchar(11)"\
)


psql ${db_name} <<__EOF
drop table if exists topics;
drop table if exists topic_statis;
create table topics (${topics_schema[@]});
create table topic_statis (${topic_statis_schema[@]});
__EOF
